'ImageListPager' => __DIR__ . '/includes/specials/SpecialListfiles.php',
'ImagePage' => __DIR__ . '/includes/page/ImagePage.php',
'ImageQueryPage' => __DIR__ . '/includes/specialpage/ImageQueryPage.php',
+ 'ImportLogFormatter' => __DIR__ . '/includes/logging/ImportLogFormatter.php',
'ImportReporter' => __DIR__ . '/includes/specials/SpecialImport.php',
'ImportSiteScripts' => __DIR__ . '/maintenance/importSiteScripts.php',
'ImportSites' => __DIR__ . '/maintenance/importSites.php',
'delete/event' => 'DeleteLogFormatter',
'delete/restore' => 'DeleteLogFormatter',
'delete/revision' => 'DeleteLogFormatter',
- 'import/interwiki' => 'LogFormatter',
- 'import/upload' => 'LogFormatter',
+ 'import/interwiki' => 'ImportLogFormatter',
+ 'import/upload' => 'ImportLogFormatter',
'managetags/activate' => 'LogFormatter',
'managetags/create' => 'LogFormatter',
'managetags/deactivate' => 'LogFormatter',
--- /dev/null
+<?php
+/**
+ * Formatter for import log entries.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @since 1.27
+ */
+
+/**
+ * This class formats import log entries.
+ *
+ * @since 1.27
+ */
+class ImportLogFormatter extends LogFormatter {
+ protected function getMessageKey() {
+ $key = parent::getMessageKey();
+ $params = $this->extractParameters();
+ if ( isset( $params[3] ) ) {
+ // New log items with more details
+ // Messages: logentry-import-upload-details, logentry-import-interwiki-details
+ $key .= '-details';
+ }
+
+ return $key;
+ }
+}
"</li>\n"
);
+ $logParams = array( '4:number:count' => $successCount );
if ( $this->mIsUpload ) {
$detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
$successCount )->inContentLanguage()->text();
- if ( $this->reason ) {
- $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
- . $this->reason;
- }
$action = 'upload';
} else {
- $interwiki = '[[:' . $this->mInterwiki . ':' .
- $foreignTitle->getFullText() . ']]';
+ $interwikiTitleStr = $this->mInterwiki . ':' . $foreignTitle->getFullText();
+ $interwiki = '[[:' . $interwikiTitleStr . ']]';
$detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
$successCount )->params( $interwiki )->inContentLanguage()->text();
- if ( $this->reason ) {
- $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
- . $this->reason;
- }
$action = 'interwiki';
+ $logParams['5:title-link:interwiki'] = $interwikiTitleStr;
+ }
+ if ( $this->reason ) {
+ $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+ . $this->reason;
}
$logEntry = new ManualLogEntry( 'import', $action );
$logEntry->setTarget( $title );
- $logEntry->setComment( $detail );
+ $logEntry->setComment( $this->reason );
$logEntry->setPerformer( $this->getUser() );
+ $logEntry->setParameters( $logParams );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
"logentry-suppress-block": "$1 {{GENDER:$2|blocked}} {{GENDER:$4|$3}} with an expiry time of $5 $6",
"logentry-suppress-reblock": "$1 {{GENDER:$2|changed}} block settings for {{GENDER:$4|$3}} with an expiry time of $5 $6",
"logentry-import-upload": "$1 {{GENDER:$2|imported}} $3 by file upload",
+ "logentry-import-upload-details": "$1 {{GENDER:$2|imported}} $3 by file upload ($4 {{PLURAL:$4|revision|revisions}})",
"logentry-import-interwiki": "$1 {{GENDER:$2|imported}} $3 from another wiki",
+ "logentry-import-interwiki-details": "$1 {{GENDER:$2|imported}} $3 from $5 ($4 {{PLURAL:$4|revision|revisions}})",
"logentry-merge-merge": "$1 {{GENDER:$2|merged}} $3 into $4 (revisions up to $5)",
"logentry-move-move": "$1 {{GENDER:$2|moved}} page $3 to $4",
"logentry-move-move-noredirect": "$1 {{GENDER:$2|moved}} page $3 to $4 without leaving a redirect",
"logentry-suppress-block": "{{Logentry}}\n* $4 - user name for gender or empty string for autoblocks\n* $5 - the block duration, localized and formatted with the english tooltip\n* $6 - block detail flags or empty string",
"logentry-suppress-reblock": "{{Logentry}}\n* $4 - user name for gender or empty string for autoblocks\n* $5 - the block duration, localized and formatted with the english tooltip\n* $6 - block detail flags or empty string",
"logentry-import-upload": "{{Logentry|[[Special:Log/import]]}}",
+ "logentry-import-upload-details": "{{Logentry|[[Special:Log/import]]}}\n* $4 - Number of imported revisions",
"logentry-import-interwiki": "{{Logentry|[[Special:Log/import]]}}",
+ "logentry-import-interwiki-details": "{{Logentry|[[Special:Log/import]]}}\n* $4 - Number of imported revisions\n* $5 - Interwiki title",
"logentry-merge-merge": "{{Logentry|[[Special:Log/merge]]}}\n* $4 - the page into which the content is merged\n* $5 - a timestamp of limit\n\nThe log and its associated special page 'MergeHistory' is not enabled by default.\n\nPlease note that the parameters in a log entry will appear in the log only in the default language of the wiki. View [[Special:Log]] for examples on translatewiki.net with English default language.",
"logentry-move-move": "{{Logentry|[[Special:Log/move]]}}\nParameter $4, the target page, is also not visible to parser functions.",
"logentry-move-move-noredirect": "{{Logentry|[[Special:Log/move]]}}\nParameter $4, the target page, is also not visible to parser functions.",
--- /dev/null
+<?php
+
+class ImportLogFormatterTest extends LogFormatterTestCase {
+
+ /**
+ * Provide different rows from the logging table to test
+ * for backward compatibility.
+ * Do not change the existing data, just add a new database row
+ */
+ public static function provideUploadLogDatabaseRows() {
+ return array(
+ // Current format
+ array(
+ array(
+ 'type' => 'import',
+ 'action' => 'upload',
+ 'comment' => 'upload comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'ImportPage',
+ 'params' => array(
+ '4:number:count' => '1',
+ ),
+ ),
+ array(
+ 'text' => 'User imported ImportPage by file upload (1 revision)',
+ 'api' => array(
+ 'count' => 1,
+ ),
+ ),
+ ),
+
+ // old format - without details
+ array(
+ array(
+ 'type' => 'import',
+ 'action' => 'upload',
+ 'comment' => '1 revision: import comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'ImportPage',
+ 'params' => array(),
+ ),
+ array(
+ 'text' => 'User imported ImportPage by file upload',
+ 'api' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideUploadLogDatabaseRows
+ */
+ public function testUploadLogDatabaseRows( $row, $extra ) {
+ $this->doTestLogFormatter( $row, $extra );
+ }
+
+ /**
+ * Provide different rows from the logging table to test
+ * for backward compatibility.
+ * Do not change the existing data, just add a new database row
+ */
+ public static function provideInterwikiLogDatabaseRows() {
+ return array(
+ // Current format
+ array(
+ array(
+ 'type' => 'import',
+ 'action' => 'interwiki',
+ 'comment' => 'interwiki comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'ImportPage',
+ 'params' => array(
+ '4:number:count' => '1',
+ '5:title-link:interwiki' => 'importiw:PageImport',
+ ),
+ ),
+ array(
+ 'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
+ 'api' => array(
+ 'count' => 1,
+ 'interwiki_ns' => 0,
+ 'interwiki_title' => 'importiw:PageImport',
+ ),
+ ),
+ ),
+
+ // old format - without details
+ array(
+ array(
+ 'type' => 'import',
+ 'action' => 'interwiki',
+ 'comment' => '1 revision from importiw:PageImport: interwiki comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'ImportPage',
+ 'params' => array(),
+ ),
+ array(
+ 'text' => 'User imported ImportPage from another wiki',
+ 'api' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideInterwikiLogDatabaseRows
+ */
+ public function testInterwikiLogDatabaseRows( $row, $extra ) {
+ // Setup importiw: as interwiki prefix
+ $this->setMwGlobals( 'wgHooks', array(
+ 'InterwikiLoadPrefix' => array(
+ function ( $prefix, &$data ) {
+ if ( $prefix == 'importiw' ) {
+ $data = array( 'iw_url' => 'wikipedia' );
+ }
+ return false;
+ }
+ )
+ ) );
+
+ $this->doTestLogFormatter( $row, $extra );
+ }
+}